﻿
config.eventcfg = {	

	query_chk: function(){
			var records = this.grid.getSelectionModel().getSelections();
			if (!JxUtil.selectone(records)) return;
			var selfunid = records[0].get('pur_apply__apply_id');
			
			//加载Form数据
			var hdcall = function(page) {
				//设置外键键
				page.getForm().fkName = 'pur_say_chk__apply_id';
				page.getForm().fkValue = selfunid;
				
				//加载显示数据
				var options = {
					where_sql: 'pur_say_chk.apply_id = ?',
					where_type: 'string',
					where_value: selfunid,
					callback: function(data) {
						//如果没有数据则执行新增
						if (data.length == 0) {
							//page.formNode.event.create();
						} else {
							var r = page.formNode.event.newRecord(data[0]);
							
							page.getForm().myRecord = r;
							page.getForm().loadRecord(r);
						}
					}
				};
				Jxstar.queryData('pur_say_chk', options);
			};
			
			//显示数据
			var define = Jxstar.findNode('pur_say_chk');
			Jxstar.showData({
				filename: define.formpage,
				title: define.nodetitle,
				pagetype:"query",
				width: 750,
				height: 400,
				callback: hdcall
			});
		},
		query_record: function(){
			var records = this.grid.getSelectionModel().getSelections();
			if (!JxUtil.selectone(records)) return;
			var selfunid = records[0].get('pur_apply__apply_id');
			
			//加载Form数据
			var hdcall = function(page) {
				//设置外键键
				page.getForm().fkName = 'pur_say_record__apply_id';
				page.getForm().fkValue = selfunid;
				
				//加载显示数据
				var options = {
					where_sql: 'pur_say_record.apply_id = ?',
					where_type: 'string',
					where_value: selfunid,
					callback: function(data) {
						//如果没有数据则执行新增
						if (data.length == 0) {
							//page.formNode.event.create();
						} else {
							var r = page.formNode.event.newRecord(data[0]);
							
							page.getForm().myRecord = r;
							page.getForm().loadRecord(r);
						}
					}
				};
				Jxstar.queryData('pur_say_record', options);
			};
			
			//显示数据
			var define = Jxstar.findNode('pur_say_record');
			Jxstar.showData({
				filename: define.formpage,
				title: define.nodetitle,
				pagetype:"query",
				width: 750,
				height: 400,
				callback: hdcall
			});
		}
};